package com.itheima.service.impl;

import com.itheima.service.RestService;
import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class RestConsumerImpl implements RestService {

    private final RestTemplate restTemplate = RestTemplateBuilder.create();

    @Override
    public String sayRest(String name) {
        String providerName = "provider2";
        //URL:cse://是协议 + 微服务名称 + 具体某个微服务访问路径
        String rtnValue = restTemplate.getForObject("cse://"+providerName+"/"+"/hello/hello?name="+name, String.class);
        return rtnValue;
    }
}
